package com.westvalley.config;


import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.AutoBindRoutes;
import com.jfinal.kit.PathKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.render.ViewType;
import com.westvalley.model._MappingKits;
import com.westvalley.plugin.db.WeaverDBPlugin;

public class AppConfig extends JFinalConfig{
	
	@Override
	public void configConstant(Constants me) {
		me.setEncoding("UTF-8");
		me.setDevMode(true);
		me.setViewType(ViewType.JSP);
	}

	@Override
	public void configRoute(Routes me) {
		PathKit.setRootClassPath("/u01/oa/ecology/classbean");
		AutoBindRoutes autoBindRoutes = new AutoBindRoutes().scanPaths("com.westvalley.ctrl");
		me.add(autoBindRoutes);
	}
	
	@Override
	public void configPlugin(Plugins me) {
		//添加连接池
		WeaverDBPlugin mainWeaverDBPlugin = new WeaverDBPlugin();
		//加载数据库连接池插件
		me.add(mainWeaverDBPlugin);
		//接入ActiveRecordPlugin插件
		ActiveRecordPlugin arp = new ActiveRecordPlugin(mainWeaverDBPlugin);
		arp.setShowSql(true);
		// 配置Oracle方言
		arp.setDialect(mainWeaverDBPlugin.getDialect());
		// 配置属性名(字段名)大小写不敏感容器工厂
		arp.setContainerFactory(new CaseInsensitiveContainerFactory());
		//添加绑定实体
		_MappingKits.mapping(arp);
		me.add(arp);
		//添加集成数据源
		//WeaverMoreDbPlugin moreWeaverDBPlugin = new WeaverMoreDbPlugin();
		//me.add(moreWeaverDBPlugin);
	}

	@Override
	public void configInterceptor(Interceptors me) {
	}

	@Override
	public void configHandler(Handlers me) {
	}
	
}
